"""
Hongyu (Vicky) Ye 
03/01/2021
Section #03
Problem#3: Rock, Paper, Scissors, Lizard, Spock!

"""

import random

print("Let's Play Rock, Peper, Scissors, Lizard, Spock!")
print()


while True:
    required_wins = int(input("How many wins is required to end the tournament? "))
    if required_wins > 0:
        break
    else:
        print("Invalid, try again.")
        
        
print()
print("OK, here we go")
print()

Round = 1
humanWinRound = 0
computerWinRound = 0

dict1 = {'R': ['0','Rock'], 'P':['1','Paper'], 'S':['2','Scissors'],'L':['3','Lizard'], 'O':['4','Spock']}
#2电脑胜，1人胜，0平局
dict2 = {'00':[0,"The round has ended in a tie! No points awarded"],
         '11':[0,"The round has ended in a tie! No points awarded"],
         '22':[0,"The round has ended in a tie! No points awarded"],
         '33':[0,"The round has ended in a tie! No points awarded"],
         '44':[0,"The round has ended in a tie! No points awarded"],
         '01':[2,'Paper covers Rock!'],         '10':[1,'Paper covers Rock!'],
         '02':[1,'Rock crushes scissors!'],     '20':[2,'Rock crushes scissors!'],
         '03':[1,'Rock crushes lizard!'],        '30':[2,'Rock crushes lizard！'],
         '04':[2,'Spock vaporizes rock!'],       '40':[1,'Spock vaporizes rock！'] ,
         '12':[2,'Scissors cut paper!'],         '21':[1,'Scissors cut paper！'],
         '13':[2,'Lizard eats paper!'],          '31':[1,'Lizard eats paper！'],
         '14':[1,'Paper disproves spock!'],      '41':[2,'Paper disproves spock！'],
         '23':[1,'Scissors decapitates lizard！'],'32':[2,'Scissors decapitates lizard！'],
         '24':[2,'Spock smashes scissors！'],     '42':[1,'Spock smashes scissors！'],
         '34':[1,'Lizard poison spock！'],        '43':[2,'Lizard poison spock！']}

while humanWinRound < required_wins:

    print("-------------------------------------")
    print("Round #"+f'{Round}')
    print("You have won",humanWinRound,"rounds")
    print("The computer has won", computerWinRound,"rounds")
    print("There have been", Round-1-humanWinRound-computerWinRound, "ties so far")
    print("-------------------------------------")
    print()

    # 正确输入
    answer = input("(R)ock, (P)aper, (S)cissors, (L)izard or Sp(O)ck: ")
    if answer in ['R', 'P', 'S', 'L', 'O']:
        humanChoice = dict1[answer][0]
    else:
        print("This is an invalid choice, please try again.")
        continue
        
    
    computerChoice = random.randint(0,4)
    computerChoice = f'{computerChoice}'

    res = humanChoice + computerChoice
    
    print("The Computer has selected", dict1[computerChoice][1],"!")
    print(dict2[res][1])

    if(dict2[res][0] == 2):
        computerWinRound += 1
        print("Computer wins\n!")
    elif(dict2[res][0] == 1):
        humanWinRound += 1
        print("You win!\n")
    
    Round += 1
    
print("The user wins the game!")